<template>
    <div class="container">
        <h3>品级定义</h3>
        <el-form ref="form" label-width="120px" style="margin-top:20px;">
            <el-form-item v-for="(item,index) in unit" :key="index+'00'" >
				<el-input v-model="item.name" style="width:100px;" ></el-input> ：
                <el-input v-model="item.represent" style="width:250px;margin-left:10px;" ></el-input>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="unit_save" class="unit_save">保存</el-button>
                <el-button  @click="added_unit" class='added_unit'>添加一条</el-button>
            </el-form-item>

        </el-form>
    </div>
</template>

<script>
    import axios from "axios"
    export default {
        name: 'unit',
        components: {},
        data() {
            return {
                unit: [],

                goback: false,
                type: '',

                addeds:true,
                edit: true,
                date: []
            };
        },
        mounted () {
            this.init();
        },
        created(){

        },
        methods: {
            init(){
				axios.get("http://grove.cpzsyun.com:81/api/control/goodsLevel/findList").then((res)=>{
					this.unit = res.data.data
				})
			},
			added_unit(){
				this.unit.push({name:'',represent:''})
			},
			unit_save(){
				axios.post("http://grove.cpzsyun.com:81/api/control/goodsLevel/save",this.unit).then((res)=>{
					this.$notify({
					    title: '提示',
					    message: '保存成功',
					    type: 'success',
					    duration: 500
					});
					this.init()
				})
			},
        },

        watch: {},
    };
</script>


<style scoped>
    .container {
        min-height: 65%;
    }

    .delete_btn {
        margin-left: 6px;
    }
</style>
